/**
 * This tiny script just helps us demonstrate
 * what the various example callbacks are doing
 */
// var Example = (function() {
//     // "use strict";

//     var elem= {};
//     var hideHandler ={};
//     var that = {};

//     that.init = function(options) {
//         elem = $(options.selector);
//     };

//     that.show = function(text) {
//         clearTimeout(hideHandler);

//         elem.find("span").html(text);
//         elem.fadeIn();

//         hideHandler = setTimeout(function() {
//             that.hide();
//         }, 4000);
//     };

//     that.hide = function() {
//         elem.fadeOut();
//     };

//     return that;
// }());

 function showSuccessDialog(str){
// <label class="control-label"><s:text name="ROUTE_VER_TAG"/></label>
// bootbox.dialog('center><h3><label class="btn-success">Success!<s:text name="Success"/></label>', [{
   bootbox.dialog("<center><h3>" + str + "</h3></center>", [{
	    "label" : "Success!",
	    "class" : "btn-success",
	    "callback": function() {
	        // Example.show("great success");
	    }
  
    }]);
  }

  function showErrorDialog( errCode , errMsg ){
  	var str = "<center><h3>"+ errCode +"</h3></center>"+"<br/>"+"<center><h3>"+ errMsg +"</h3></center>";
   	bootbox.dialog( str, [{
	    "label" : "Error!",
	    "class" : "btn-danger",
	    "callback": function() {
	        // Example.show("great success");
	    }
  
    }]);
  }
    function showWarnningDialog(options){
        var defaults = {
            callbackFn : null
        };
        var config = $.extend(defaults, options || {});
        var resultObj={
            result:false
        };
        bootbox.confirm("<p><h3>"+ options.errMsg+"</h3></p>", function(result) {
            resultObj.result = result ;
            if ( typeof config.callbackFn == 'function') {
                config.callbackFn(resultObj);
            }
        });
    }
  (function($){
    $.fn.extend({
    	"showCallBackWarnningDialog" : function(options) {
    		var defaults = {
		           callbackFn : null
		        }
	     	var config = $.extend(defaults, options || {});
	        var resultObj={
	        		  result:false
	        }
	        bootbox.confirm("<p><center><h3>"+ options.errMsg+"</h3></center></p>", function(result) {
			  	// Example.show("Confirm result: "+result);
			  	resultObj.result = result ;
			  	if ( typeof config.callbackFn == 'function') { 
                	config.callbackFn(resultObj); 
            	}
			}); 
			
		}
	})
   })(jQuery);
